home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / powervww / pvcmdgen.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-05  |  4.9 KB  |  204 lines

  1. //  ____________________________________________________
  2. // |                                                    |
  3. // |  Project:     POWER VIEW INTERFACE                 |
  4. // |  File:        PVCMDGEN.H                           |
  5. // |  Compiler:    WPP386 (10.6)                        |
  6. // |                                                    |
  7. // |  Subject:     Command generators interface         |
  8. // |                                                    |
  9. // |  Author:      Emil Dotchevski                      |
  10. // |____________________________________________________|
  11. //
  12. // E-mail: zajo@geocities.com
  13. // URL:    http://www.geocities.com/SiliconValley/Bay/3577
  14.  
  15. void __init_cmdgen( void );
  16.  
  17. #ifndef _PVCMDGEN_H
  18. #define _PVCMDGEN_H
  19.  
  20. //MENU DEFINES
  21.  
  22. struct Tmenu_item;
  23.  
  24. struct Tmenu
  25. {
  26.   Tmenu_item *items;        //points to a list of items
  27.   Tmenu_item *current;      //points to the default item
  28.   Tmenu *old_menu;
  29.   Tmenu_item *old_item;
  30. };
  31.  
  32. struct Tmenu_item
  33. {
  34.   Tmenu_item *next;         //points to the next menu item
  35.   char *name;               //points to the item's title
  36.   boolean enabled;
  37.   uint command;             //also used as item identifier
  38.   uint help_ctx;
  39.   uint kind;
  40.   union
  41.   {
  42.     Tmenu *submenu;         //points to nested submenu
  43.     char *param;            //points to item's parameter
  44.     uint *check;            //points to item's check uint
  45.   } what;
  46. };
  47.  
  48. class Tmenu_base: public Titem
  49. {
  50.   public:
  51.     Titem *client;
  52.     Tmenu *menu;
  53.     uint shortcut;
  54.     Tmenu_base( int _xl, int _yl );
  55.     virtual ~Tmenu_base( void );
  56.     virtual uint exec( void );
  57.  
  58.   protected:
  59.     Tset local_commands;
  60.     Tmenu_base *parent;
  61.     boolean pulled_down;
  62.     virtual void set_palette( void );
  63.     virtual void event_handler( Tevent &ev );
  64.     void update_commands( Tmenu *m );
  65.     Tmenu_item *next_line( void );
  66.     Tmenu_item *previous_line( void );
  67.     virtual int item_x( Tmenu_item *p ) = 0;
  68.     virtual int item_y( Tmenu_item *p ) = 0;
  69.     virtual Tmenu_item *pointed_ptr( int mx, int my ) = 0;
  70.     virtual Tmenu_item *shortcut_ptr( uint ascii );
  71.     void suspend_selection( void );
  72.     void open_submenu( void );
  73.     void close_submenu( void );
  74.     void close_menu( void );
  75.  
  76.     inline void make_selection( void )
  77.     {
  78.       message( this, cmMENU_SELECTION );
  79.     }
  80.  
  81.     inline void selection_made( void )
  82.     {
  83.       modal_broadcast( cmMENU_SELECTION_MADE );
  84.     }
  85.  
  86.     inline void cancelled( void )
  87.     {
  88.       modal_broadcast( cmMENU_CANCELLED );
  89.     }
  90. };
  91.  
  92. class Tmenu_box: public Tmenu_base
  93. {
  94.   public:
  95.     Tmenu_box( Tmenu *_menu, Tmenu_base *_parent );
  96.  
  97.   protected:
  98.     virtual void draw( void );
  99.     virtual void initialize( void );
  100.     virtual void event_handler( Tevent &ev );
  101.     virtual int item_x( Tmenu_item *p );
  102.     virtual int item_y( Tmenu_item *p );
  103.     virtual Tmenu_item *pointed_ptr( int mx, int my );
  104. };
  105.  
  106. class Tmenu_bar: public Tmenu_base
  107. {
  108.   public:
  109.     Tmenu_bar( Tmenu *_menu, int _xl );
  110.  
  111.   protected:
  112.     virtual void draw( void );
  113.     virtual void event_handler( Tevent &ev );
  114.     virtual int item_x( Tmenu_item *p );
  115.     virtual int item_y( Tmenu_item *p );
  116.     virtual Tmenu_item *pointed_ptr( int mx, int my );
  117. };
  118.  
  119.  
  120. //TOOLS DEFINES
  121.  
  122. typedef void ( * Tcontext_handler ) ( int context );
  123.  
  124. #endif //_PVCMDGEN.H
  125.  
  126. #ifdef DECLARE_PVCMDGEN
  127.  
  128. //MENU DECLARATIONS
  129.  
  130. #ifndef NOMAINMENU
  131. Tmenu_bar *main_menu = NULL;
  132. #endif
  133.  
  134. //TOOLS DECLARATIONS
  135.  
  136. #ifndef NOTOOLBAR
  137. uint toolbar_enabled = cmWINDOW_TOOLBAR;
  138. Titem *toolbar;
  139. #endif
  140.  
  141. #else //DECLARE_PVCMDGEN
  142.  
  143. //MENU DECLARATIONS
  144.  
  145. #ifndef NOMAINMENU
  146. extern Tmenu_bar *main_menu;
  147. #endif
  148.  
  149.  
  150. //TOOLS DECLARATIONS
  151.  
  152. #ifndef NOTOOLBAR
  153. extern uint toolbar_enabled;
  154. extern Titem *toolbar;
  155. #endif
  156.  
  157. #endif //DECLARE_PVCMDGEN
  158.  
  159.  
  160. //MENU INTERFACE
  161.  
  162. #ifndef NOMAINMENU
  163. Tmenu_bar *construct_main_menu( Tmenu *m );
  164. #endif
  165.  
  166. #ifndef NOLOCALMENU
  167. Tmenu_box *construct_local_menu( Tmenu *m );
  168. #endif
  169.  
  170. Tmenu_box *construct_menu_box( Tmenu *m );
  171. Tmenu_bar *construct_menu_bar( Tmenu *m, int _xl );
  172.  
  173. void menu( void );
  174. Tmenu *endm( void );
  175. void update_menu( Tmenu *cm, Tmenu_item *ci );
  176. Tmenu_item *mitem( char *name, uint command );
  177. Tmenu_item *mitem( char *name, char *param, uint command);
  178. Tmenu_item *mitem( char *name, uint &_check, uint command );
  179. Tmenu_item *mitem( void );
  180. Tmenu_item *submenu( char *name );
  181. void dispose_menu( Tmenu *p );
  182. void show_menu_cursor( Tmenu *p );
  183. void show_submenu_cursor( Tmenu_item *p );
  184.  
  185.  
  186. //TOOLS INTERFACE
  187.  
  188. #ifndef NOTOOLBAR
  189. void construct_toolbar( void );
  190. #endif
  191.  
  192. #ifndef NOTOOLBAR
  193. Tbutton *add_tool( char *t, uint cmd, uint key );
  194. Tbutton *add_tool( char *t, uint cmd );
  195. void add_tool( uint cmd, uint key );
  196. #endif
  197.  
  198. void install_context_handler( Tcontext_handler ctxhnd );
  199. void set_context( int context );
  200. void update_context( void );
  201.  
  202. void global_key( uint cmd, uint key );
  203. void local_key( Titem *p, uint cmd, uint key );
  204.